import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_give/common_ui/web/webview_widget.dart';

import 'package:flutter_give/pages/Home/eqaddtype.dart';

import 'package:flutter_give/pages/auth/login_page.dart';
import 'package:flutter_give/pages/auth/register_page.dart';
import 'package:flutter_give/pages/auth/reset_password.dart';
import 'package:flutter_give/pages/subpackage/agreement_page.dart';
import 'package:flutter_give/pages/subpackage/savepassword_page.dart';
import 'package:flutter_give/pages/subpackage/share_page.dart';
import 'package:flutter_give/pages/tab_page.dart';


import '../common_ui/web/webview_page.dart';
import '../pages/Home/home_page.dart';
import '../pages/subpackage/about_us_page.dart';
import '../pages/subpackage/feedback_page.dart';
import '../pages/subpackage/privacy_page.dart';
import '../pages/subpackage/regards_page.dart';
import '../pages/subpackage/setting_page.dart';
import '../pages/subpackage/unsubscribe_page.dart';


/// 路由文件
class Routes {
  static MaterialPageRoute generateRoute(RouteSettings settings) {
    switch (settings.name) {
      case RoutePath.tab:
        // return pageRoute(HomePage(),settings:settings);
        // GlobalData.store.dispatch(updateHome());
        pageRoute(TabPage(), settings: settings);
        break;
      case RoutePath.EqaddTypePage:
        return pageRoute(EqaddTypePage(title: "添加设备"), settings: settings);
      case RoutePath.loginPage:
        return pageRoute(LoginPage());
      case RoutePath.registerPage:
        return pageRoute(RegisterPage());
      case RoutePath.aboutUsPage:
        return pageRoute(AboutUsPage());
      case RoutePath.resetPassword:
        return pageRoute(ResetpassPage());
      case RoutePath.SettingPage:
        return pageRoute(SettingPage());
      case RoutePath.regardsPage:
        return pageRoute(RegardsPage());
      case RoutePath.unsubscribePage:
        return pageRoute(UnsubscribePage());
      case RoutePath.FeedbackPage:
        return pageRoute(FeedbackPage());
      case RoutePath.privacyPage:
        return pageRoute(privacyPage());
      case RoutePath.AgreementPage:
        return pageRoute(AgreementPage());
      case RoutePath.savepasswordPage:
        return pageRoute(SavepasswordPage());
    }
    return pageRoute(Scaffold(
      body: SafeArea(
        child: Center(
          child: Text("路由: ${settings.name} 不存在"),
        ),
      )
    ));
    // return pageRoute(TabPage());
  }

  // 封装跳转方法
  // MaterialPageRoute - 自带方法-自带参数提前封装好
  static MaterialPageRoute pageRoute(
    Widget page, {
    RouteSettings? settings,
    bool? fullscreenDialog,
    bool? maintainState,
    bool? allowSnapshotting,
  }) {
    return MaterialPageRoute(
        builder: (context) {
          return page;
        },
        settings: settings,
        fullscreenDialog: fullscreenDialog ?? false,
        maintainState: maintainState ?? true,
        allowSnapshotting: allowSnapshotting ?? true);
  }
}

// 路由地址
// 右边值只要不一样即可 不影响跳转  代表唯一id作用
class RoutePath {
  // 首页
  // static const String home = "/";
  static const String tab = "/";

  // 网页页面
  static const String webViewPage = "/web_View_page";

  // 登录页面
  static const String loginPage = "/login_page";

  // 注册页面
  static const String registerPage = "/register_page";

  // 忘记密码
  static const String resetPassword = "/reset_password";

  // 修改密码
  static const String savepasswordPage = "/savepassword_page";

  // 关于我们
  static const String aboutUsPage = "/about_us_page";

  // 关于我们
  static const String FeedbackPage = "/Feedback_page";

  // 添加设备
  static const String EqaddTypePage = "/eqadd_type_page";

  // 配置设备
  static const String PairingPage = "/pairing_page";

  // 设置页面
  static const String SettingPage = "/setting_page";

  // 关于我们
  static const String regardsPage = "/regards_page";

  // 隐私政策
  static const String privacyPage = "/privacy_page";

  // 用户协议
  static const String AgreementPage = "/Agreement_page";

  // 注销账号
  static const String unsubscribePage = "/unsubscribe_page";

  // 分享页面
  static const String SharePage = "/share_page";

  // P2P页面 - 直播页面
  static const String P2P = "/P2P";
}
